package com.psycho.sys.api.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.psycho.sys.api.entity.User;
import com.psycho.sys.api.entity.Counselor;
import com.psycho.sys.api.mapper.UserMapper;
import com.psycho.sys.api.mapper.CounselorMapper;
import com.psycho.sys.api.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户服务实现类
 */
@Service
@Transactional
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private CounselorMapper counselorMapper;

    @Override
    public User findByUsername(String username) {
        return lambdaQuery().eq(User::getUsername, username).one();
    }

    @Override
    public boolean saveCounselor(Counselor counselor) {
        return counselorMapper.insert(counselor) > 0;
    }
}